package com.me.iot.server.socket;

import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;

/**
 * @author mingke
 * @desc 接收Socket客户端发过来信息的回调函数
 * @time 2022/5/10
 */
public class MeIOTReadHandler implements CompletionHandler<Integer, ByteBuffer> {
    //通信信道
    private AsynchronousSocketChannel socketChannel;

    public MeIOTReadHandler(AsynchronousSocketChannel socketChannel) {
        this.socketChannel = socketChannel;
    }

    @Override
    public void completed(Integer result, ByteBuffer buffer) {
        if(result == -1) { //客户端断开连接的标志，通常还要加上心跳包做双重判断客户端下线

        }else {

        }
    }

    @Override
    public void failed(Throwable exc, ByteBuffer buffer) {

    }
}
